/*
 ============================================================================
 Name        : decode.h
 Author      :
 Version     :	1
 Copyright   : Your copyright notice
 Description : Perform properly disassembly process. Identifies if the byte analyzed
  corresponds to a prefix, opcode, or is a record, use the information provided by
  the XML file for this analysis
 ============================================================================
 */

#ifndef ENCODING_H_
#define ENCODING_H_

#include <config.h>
#include <debug.h>
#include <elf.h>
#include <gelf.h>
#include <libelf.h>
#include <err.h>
#include <fcntl.h>
#include <libelf.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <common.h>
#define TWO_BYTE_OPCODE (0x0F)

#define REG_TO_MEM         0
#define MEM_TO_REG         1
#define OPERAND_SIZE_8     0
#define OPERAND_SIZE_16_32 1
#define MAX_OPERAND_NUMBER 4

///<Lists the different instruction sizes
typedef enum
{
	SIZE_8 = 8, SIZE_16=16, SIZE_32=32, SIZE_64=64
} INST_DATA_SIZE;
///<A structure containing the different record types according to their size
typedef struct _reg_values
{
	char *string; ///<Register name
	char regValue; ///<Register value
	INST_DATA_SIZE size; ///<Register size
} REG_VALUES;


typedef union _optional
{
	unsigned char value;
	struct
	{
		unsigned char ss :2;
		unsigned char index :3;
		unsigned char base :3;
	};
} OPTIONAL;

typedef struct _displacement
{
	unsigned char value;
} DISPLACEMENT;

typedef struct _inmediate
{
	unsigned char value;
} INMEDIATE;


char decode(char* buf, UINT8 *decodedSize, MACHINE_INSTRUCTION *instructionDecoded);

#endif /* ENCODING_H_ */
